<?php
    
    class Admin extends Core{
    	
		public function __construct(){
			parent::__construct();
			
		}
		
		public function setPlugIn(){
			return array("editor.php","page.php");
		}
		
		public function Index(){
			$this->mod = "Index";
			if(!$_SESSION['U']['adminid']){
				$this->showmessage("您还未登录","?m=Admin/Login" ,2000, "管理员登录");
			}else{
				$this->_T['U'] = $_SESSION['U'];
				$this->template();
			}
		}
		
		public function Login(){
			$this->mod = "Login";	
			$this->template();
		}
		
		public function LoginDeal(){
			if($_POST['login']){
				$admin = $_POST['name'];
				$adminRow = DB::fetch_row("select * from `ntwt_admin` where `admin`='{$admin}'");
				if(!is_array($adminRow)){
					$this->showmessage("管理员不存在！","?m=Admin/Login" ,2000, "返回登陆页");
				}
				if(md5(md5($_POST['psw']).$adminRow['salt'])==$adminRow['psw']){
					$_SESSION['U']['adminid'] = $adminRow['adminid'];
					$_SESSION['U']['admin']   =  $adminRow['admin'];
					$this->showmessage("登陆成功！","?m=Admin/Index" ,2000, "进入后台");
				}else{
					$this->showmessage("密码有误！","?m=Admin/Login" ,2000, "返回登陆页");
				}
			}
		}
		
		public function Out(){
			$_SESSION['U'] = null;
			$this->showmessage("安全退出","?m=Admin/Login" ,2000, "返回登陆页");
		}
    }




?>